package org.minos.edit.view
{
	import flash.events.Event;
	import org.aswing.event.SelectionEvent;
	import org.minos.edit.EditFacate;
	import org.minos.edit.model.vo.ItemVO;
	import org.minos.edit.view.components.SceneTable;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	/**
	 * ...
	 * @author Minos
	 */
	public class TableMediator extends Mediator
	{
		public static const NAME : String = "TableMediator";
		
		public function TableMediator( v : SceneTable )
		{
			super( NAME , v );
		}
		
		public function get table() : SceneTable
		{
			return viewComponent as SceneTable;
		}
		
		override public function onRegister() : void
		{
			super.onRegister();
			table.addEventListener( SelectionEvent.ROW_SELECTION_CHANGED , onRowSelectionChanged );
			table.addEventListener( SceneTable.LABEL_CHANGED , __onLabelChanged );
		}
		
		override public function onRemove() : void
		{
			super.onRemove();
		}
		
		private function __onLabelChanged(e:Event):void 
		{
			sendNotification( SceneTable.LABEL_CHANGED );
		}
		
		private function onRowSelectionChanged( e : SelectionEvent ) : void
		{
			sendNotification( EditFacate.SCENE_SELECTION_CHANGED , table.getSelectedVO() );
		}
		
		override public function listNotificationInterests() : Array
		{
			return [];
		}
		
		override public function handleNotification( notification : INotification ) : void
		{
			super.handleNotification( notification );
		}
	}

}